/*
 * Project Name: jmax
 * File Name: JmaxController.java
 * Copyright: Copyright(C) 1985-2015 ZKTeco Inc. All rights reserved.
 */
package com.xdtech.jmax.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.codehaus.jackson.map.util.JSONPObject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.xdtech.common.exception.BusinessException;
import com.xdtech.jmax.vo.DeviceEventLogItem;
import com.xdtech.sys.aspect.SystemControllerLog;
import com.xdtech.web.model.Pagination;
import com.xdtech.web.model.ResultMessage;

/**
 * TODO 一句话功能简述，请确保和下面的block tags之间保留一行空行
 * <p>
 * TODO 功能详细描述，若不需要请连同上面的p标签一起删除
 * 
 * @author <a href="max.zheng@zkteco.com">郑志雄</>
 * @version TODO 添加版本
 * @see 相关类或方法，不需要请删除此行
 * @since 2015-1-27 下午5:16:47
 */
@Controller
@Scope("prototype")
public class JmaxController
{
	@RequestMapping("/about.do")
	public ModelAndView about(HttpServletRequest request) {
		return new ModelAndView("jmax/jmaxAbout_ftl");
	}
	
	@RequestMapping("/test.action")
	public ModelAndView test(HttpServletRequest request) {
		throw new BusinessException();
//		return new ModelAndView("jmax/test/test_ftl");
	}
	@RequestMapping("/jmaxtest.action")
	public ModelAndView jmaxtest(HttpServletRequest request) {
		return new ModelAndView("jmax/test/test_ftl");
	}
	
	@RequestMapping("/jmax.action")
	public ModelAndView skip(String page) {
		return new ModelAndView(page+"_ftl");
	}
	
	@RequestMapping("/deviceEventMoniting.do")
	public ModelAndView deviceEventMoniting(HttpServletRequest request) {
		return new ModelAndView("jmax/monitor/deviceEventMoning_ftl");
	}
	@RequestMapping(value="loadEventGridDatas",params="loadGridDatas")
	@ResponseBody
	public Map<String, Object> loadEventGridDatas(HttpServletRequest request,Pagination pg) {
		Map<String, Object> results = new HashMap<String, Object>();
		List<DeviceEventLogItem> items = new ArrayList<DeviceEventLogItem>();
		for (int i = 0; i < 30; i++) {
			items.add(new DeviceEventLogItem());
		}
		results.put("total", 0);
		results.put("rows", items);
		return results;
	}
	
	@RequestMapping(value ="/jmaxJsonp.action")  
	@ResponseBody  
	@SystemControllerLog(description="JSONP测试")
	public JSONPObject jmaxJsonp(String callback){  
		Map<String, Object> results = new HashMap<String, Object>();
		List<DeviceEventLogItem> items = new ArrayList<DeviceEventLogItem>();
		for (int i = 0; i < 30; i++) {
			items.add(new DeviceEventLogItem());
		}
		results.put("total", 0);
		results.put("rows", items);
		ResultMessage rs = new ResultMessage();
		rs.setObj(results);
	    return new JSONPObject(callback,rs);  
	} 
	
	@RequestMapping(value ="/jmaxVoid.action")  
	@ResponseBody  
	@SystemControllerLog(description="JSONP测试")
	public void jmaxVoid(String callback){  
		return;
	} 
}
